﻿using System;

namespace SvnFlow
{
    public abstract class MergeConflict
    {
        public readonly string m_conflictType;

        public string Path { get; private set; }

        protected MergeConflict(string path, string conflictType)
        {
            Path = path;
            m_conflictType = conflictType;
        }

        public new string ToString()
        {
            return String.Format("{0}: {1}", m_conflictType, Path);
        }

        public bool Equals(MergeConflict obj)
        {
            if (ReferenceEquals(obj, null)) return false;
            if (ReferenceEquals(obj, this)) return true;
            return
                obj.Path == Path
                && obj.m_conflictType == m_conflictType;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(obj, null)) return false;

            var obj1 = obj as MergeConflict;
            if (ReferenceEquals(null, obj1)) return false;

            return Equals(obj1);
        }

        public override int GetHashCode()
        {
            return (Path + "|" + m_conflictType).GetHashCode();
        }
    }
}
